<script type="text/javascript" src="<?=base_url()?>resource/js/layer/layer.js"></script>
<script type="application/javascript">
    $(function(){
        $("select[data-edit-select]").filterSelect();
		
        var bool=<?php if(isset($productFirst['inWarranty']) && (!empty($productFirst['repairItem']) || !empty($productFirst['supplementRepairItem']) ) ) { echo 'true';}else{  echo 'false';}?>;
        var status=<?=$productFirst['status_id']?>;
        if(bool && status==3){
            $("form[id='wxFrom'] :text").attr("disabled",'disabled');
            $("form[id='wxFrom'] textarea").attr("disabled",'disabled');
            $("form[id='wxFrom'] select").attr("disabled",'disabled');
            $("form[id='wxFrom'] :radio").attr("disabled",'disabled');
            $("form[id='wxFrom'] :checkbox").attr("disabled",'disabled');
            var target_top = $("#partsFormId").offset().top;
            $("html,body").scrollTop(target_top);
        }
    });
function myform_submit() {
    //是否质保
    var inWarranty = $("input[name='inWarranty']:checked").val();
    if(!inWarranty){
        alert('<?=lang('product_qxzsfzb')?>');
        return false;
    }else{
        if(inWarranty==0 && inWarranty!="<?=$productFirst['inWarranty']?>"){
            var warranty_img_1=$("input[name='warranty_img_1']").val();
            var warranty_img_2=$("input[name='warranty_img_2']").val();
            var warranty_img_3=$("input[name='warranty_img_3']").val();
            var warranty_remark_rp=$("textarea[name='warranty_remark_rp']").val();
            if(warranty_img_1=='' && warranty_img_2=='' && warranty_img_3==''){
                alert('<?=lang('product_qscbwtp')?>');
                return false;
            }
            if(warranty_remark_rp==''){
                alert('<?=lang('product_qxzbwbz')?>');
                return false;
            }
        }
    }
    //附件
    var repairItem = $("#repairItemDivId :checkbox:checked");
    if(repairItem.length<=0){
        alert('<?=lang('product_qxzwxx')?>');
        return false;
    }
}
    function peijian(){
        //配件
        var isAddParst = true;
        var itemArr = [];
        $('input[name="repairItem[]"]:checked').each(function(){
            itemArr.push($(this).val());
        })
        console.log(itemArr);
        $.ajax('<?=blang_url('common/Com_ajax/verifyIsPart')?>',
            {
                type:'post',
                async: false,
                data: {'id': $("input[name=id]").val(),'itemArr':itemArr},
                dataType:'json',
                success:function(result){
                    if(result.data == '-1'){
                        isAddParst = result.success;
                        alert(result.message);
                    }else if(!result.success){
                        isAddParst = confirm(result.message);
                    }
                }
            }
        );
        //return false;
        return isAddParst;
    }
    //环球提示信息跳转
    function hqUrl(){
        window.location.href='<?=blang_url('products/Product_new/inDetails/'.$productFirst['id'])?>';
    }
    /*function GlobalEGrowSync(){
        var item={'pid':<?=$productFirst['id']?>,'saveFittingInfo':1,'PayInfo':1};
        $.post("<?=blang_url('ajax/ajax/GlobalEGrowSync')?>",item,function(data){
            if(data=='101'){
                $('#hqpjMsg').html("<span style='color: #ff0000'>失败(环球易购通信故障)</span>");
            }else{
                var object=JSON.parse(data);
                if(object['saveFittingInfo']['code']===0){
                    $('#hqpjMsg').html("<span style='color: #00ee00'>成功!</span>");
                }else{
                    $('#hqpjMsg').html("<span style='color: #ff0000'>失败("+object['msg']+")</span>");
                }
                if(object['PayInfo']['code']===0){
                    $('#hqbjMsg').html("<span style='color: #00ee00'>成功!</span>");
                }else{
                    $('#hqbjMsg').html("<span style='color: #ff0000'>失败("+object['msg']+")</span>");
                }
            }
        });
    }*/
    //维修报价
    function quoteRepair(){
        if(peijian()){
            var index=layer.load(2);
            $.ajax({
                type: "POST",
                url:"<?=blang_url('products/Product_new/ProductQuote')?>",
                data: {'id':<?=$productFirst['id']?>},
                success: function (data) {
                    if(data.success) {
                        $.messager.alert('系统提示信息', data.data.hint, 'info', function () {
                            window.location.href = data.data.url;
                        });
                    }else{
                        $.messager.alert('系统提示信息', "提交失败："+data.message, 'error');
                    }
                },
                error: function(data) {
                    $.messager.alert('系统提示信息', "提交失败："+data, 'error');
                },
                complete: function(){
                    layer.close(index);
                }
            });
        }
        return false;
    }

</script>
<style type="text/css">
    #search{font-size:14px;}
    #search input{padding:2px 1px; width:600px; height: 26px; line-height: 26px;}
    #search_auto{
        border:1px solid #817FB2; position:absolute;display:none;
        width:800px; max-height: 400px; overflow:auto;padding-top: 5px;
    }
    #search_auto li{background:#FFF; text-align:left;}
    #search_auto li a{display:block; padding:4px 5px; cursor:pointer; color:#666;}
    #search_auto li a:hover{background:#D8D8D8; text-decoration:none; color:#000;}
    .layer_notice {
        float: left;
        height: 75px;
        width: 330px;
        background: #F1EFF4;
        overflow: hidden;
        padding: 10px;
    }
</style>
<!--菜单 start-->
<?php $this->load->view('defaults/common/left');?>
<!--菜单 end-->
<div id="content">
    <div class="page-header">
        <div class="container-fluid">
        <h1><?=lang('order_wxbj')?></h1>
        <?=$this->breadcrumb->generateHTML();?>
        </div>
    </div>
    <div class="container-fluid">
        <div class="panel panel-default">
            <div class="panel-heading">
                <h3 class="panel-title"><i class="fa fa-pencil"></i><?=lang('order_wxbj')?></h3>
            </div>
            <div class="panel-body">
                <div class="table-responsive">
                    <form class="form-horizontal" action="<?=blang_url('products/Product_new/'.$post_type)?>" method="post" id='wxFrom' name="myform" onsubmit="return myform_submit()" autocomplete="off" enctype="multipart/form-data" style="overflow: hidden;">
                        <div class="form-group">
                            <label class="col-sm-2 control-label">订单信息</label>
                            <div class="col-sm-10">
                                <table class="table table-bordered table-hover oms-table" cellspacing="0">
                                    <thead>
                                        <tr>
                                            <th class="text-left"><?=lang('order_wxdh')?></th>
                                            <th class="text-left"><?=lang('order_wxlx')?></th>
                                            <th class="text-left"><?=lang('order_zt')?></th>
                                            <th class="text-right"><?=lang('product_cplx')?></th>
                                            <th class="text-right">SKU</th>
                                            <?php if($productFirst['product_brand']): ?>
                                            <th class="text-right">brand/model</th>
                                            <?php endif;?>
                                        </tr>
                                    </thead>
                                    <tbody>
                                    <tr>
                                        <td class="text-left"><?=$productFirst['order_num']?></td>
                                        <td class="text-left"><?=$productFirst['serviceTypeName']?></td>
                                        <td class="text-left"><?=$productFirst['statusName']?></td>
                                        <td class="text-right"><?=$productFirst['category_name']?></td>
                                        <td class="text-right"><?=$productFirst['productSku']?></td>
                                        <?php if($productFirst['product_brand']): ?>
                                        <td class="text-right"><?=$productFirst['product_brand']?>/<?=$productFirst['product_model']?></td>
                                        <?php endif;?>
                                    </tr>
                                    </tbody>
                                </table>
                                <?php if($brandCustomer): ?>
                                <h3 class="panel-title"><?=lang('product_ppkhxx')?></h3>
                                <table class="table table-bordered table-hover oms-table" cellspacing="0">
                                    <thead>
                                        <tr>
                                            <th class="text-left"><?=lang('product_ppkhmc')?></th>
                                            <th class="text-right"><?=lang('product_ppkhbh')?></th>
                                        </tr>
                                    </thead>
                                    <tbody>
                                    <tr>
                                        <td class="text-left"><?=$brandCustomer['name']?></td>
                                        <td class="text-right"><?=$brandCustomer['id']?></td>
                                    </tr>
                                    </tbody>
                                </table>
                                 <?php endif;?>
                                 <table class="table table-bordered table-hover oms-table" cellspacing="0">
                                    <tbody>
                                    <tr>
                                        <td class="text-right" style="width:10%;"><?=lang('product_khbz')?></td>
                                        <td class="text-left" style="width:90%;"><?=$productFirst['customerRemark']?></td>
                                    </tr>
                                    <?php if($productFirst['defectDes']): ?>
                                    <tr>
                                        <td class="text-right" style="width:10%;"><?=lang('product_gzms')?></td>
                                        <td class="text-left" style="width:90%;"> <?=$productFirst['defectDes']?></td>
                                    </tr>
                                    <?php endif;?>
                                    </tbody>
                                </table>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-2 control-label"><?=lang('product_cpzt')?></label>
                            <div class="col-sm-10">
                              <label class="oms-radio">
                                    <input type="radio" name="available" value="0"  <?=$ckdAvailable['0']?> />delete
                                </label>
                                <label class="oms-radio">
                                    <input type="radio" name="available" value="1"  <?=$ckdAvailable['1']?> />normal
                                </label>
                                <label class="oms-radio">
                                   <input type="radio" name="available" value="2"  <?=$ckdAvailable['2']?> />hold
                                </label>
                            </div>
                        </div>
                        
                        <div class="form-group">
                            <label class="col-sm-2 control-label"><?=lang('product_sfzb')?></label>
                            <div class="col-sm-10">
                                <label class="oms-radio">
                                    <input type="radio" class="inputinWarranty input-no" name="inWarranty" value="0"  <?=$ckdInWarranty['0']?> />No
                                </label>
                                <?php if($productFirst['inWarranty']==='0'):?>
                                <label class="oms-radio">
                                     <input type="radio" class="inputinWarranty" name="inWarranty" value="1" disabled />Yes
                                </label>       
                                <?php else: ?>
                                <label class="oms-radio">
                                   <input type="radio" class="inputinWarranty" name="inWarranty" value="1"  <?=$ckdInWarranty['1']?> />Yes
                                </label>
                                <?php endif;?>
                                <label style="color:#1e91cf;">Note：<?=lang('product_sfzbnote')?></label>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-2 control-label"><?=lang('product_wxx')?></label>
                            <div class="col-sm-10">
                                <div id="repairItemDivId">
                                <?php foreach ($repairItemList as $rs):?>
                                    <label class="oms-radio">
                                         <input type="checkbox" name="repairItem[]" value="<?=$rs['id']?>"  <?=$ckdRepairItem[$rs['id']]?> ><?=$rs['name_'.$curLang]?>
                                    </label> 
                                <?php endforeach;?>
                                </div>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-2 control-label"><?=lang('product_wxsbz')?></label>
                            <div class="col-sm-10">
                                <textarea class="form-control" name="technicianRemark"><?=$productFirst['technicianRemark']?></textarea>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-2 control-label"><?=lang('product_bwbzwx')?></label>
                            <div class="col-sm-10">
                                <textarea class="form-control" name="warranty_remark_rp"><?=$productFirst['warranty_remark_rp']?></textarea>
                            </div>
                        </div>

                        <div class="form-group">
                            <label class="col-sm-2 control-label"></label>
                            <div class="col-sm-10">
                              <input name="id" type="hidden" value="<?=$productFirst['id']?>" />
                              <?php if(isset($productFirst['inWarranty'])&& isset($productFirst['repairItem']) && $productFirst['status_id']==3){?>
                                  ↓↓↓
                              <?php }else{?>
                            <input class="btn btn-primary pull-right" style="padding:8px 30px;margin-left: 5px;" type="submit" value="<?=lang('public_tj')?>" name="submits" />
                            <input class="btn btn-oms pull-right" style="padding:8px 30px;" type="reset" value="reset" name="resetProduct" />
                              <?php }?>
                            </div>
                        </div>
                    </form>
                    <div class="form-horizontal" style="overflow:hidden;display: <?php if(isset($productFirst['inWarranty'])&& isset($productFirst['repairItem'])){ echo 'block';}{  echo 'none';} ?>">
                        <div class="form-group">
                            <label class="col-sm-2 control-label"><?=lang('peijian_tjpj')?></label>
                            <div class="col-sm-10">
                             <div class="ct_content" id="partsListId"></div>
                              <form action="<?=blang_url('common/Com_ajax/addParts')?>" method="post" name="partsForm" id="partsFormId" autocomplete="off" enctype="multipart/form-data">
                                <table class="style20170608" cellspacing="0">
                                    <tbody>
                                    <tr>
                                        <td class="tableSubtitle odd"><?= lang('query_scope') ?></td>
                                        <td class="tableContent" colspan="3">
                                            <label class="oms-radio">
                                               <input type="radio" name="scope" value="1" <?=$partsList?'':'checked'?>><?= lang('all_parts') ?>
                                            </label>
                                             <label class="oms-radio">
                                               <input type="radio" name="scope" value="2" <?=$partsList?'checked':''?>><?= lang('parts_for_this_model') ?>
                                            </label>
                                            <?php if($partsPosition && $partsList){?>
                                            <div id="partsPosition">
                                                <h3 class="panel-title" style="margin: 10px 0 5px 0;"><?= lang('area') ?>:</h3>
                                                <select class="form-control" name="position" id="position" data-edit-select="1"  onchange="keyUp()">
                                                    <option value=""><?= lang('all_parts') ?></option>
                                                    <?php foreach($partsPosition as $row){ ?>
                                                        <option value="<?=$row['sap_id']?>"><?=$row['name']?></option>
                                                    <?php }?>
                                                </select>
                                                <br>
                                            </div>
                                            <?php }?>
                                        </td>                                                            
                                    </tr>
                                     <tr>
                                        <td class="tableSubtitle even"><?=lang('peijian_pjmc')?></td>
                                        <td class="tableContent" colspan="3">
                                            <div id="search" style="display: <?=$partsList?'none':'block'?>">
                                                <input class="form-control" name="name" id='name_name' placeholder="<?=lang('peijian_searchNote')?>" autocomplete="off" />
                                            </div>
                                            <div id="search_auto" style="margin-top: -1px;"></div>
                                            <div id="part_list">
                                                <select class="form-control" style="display: <?=$partsList?'block':'none'?>" name="name_select" id="part_select" onchange="addParts_two($(this).val(),2)">
                                                    <option value="">--请选择--</option>
                                                    <?php foreach($partsList as $rs){?>
                                                        <option value="<?=$rs['jsonData']?>"><?=$rs['name']?>&nbsp;&nbsp;<?=$rs['sku']?></option>
                                                    <?php }?>
                                                </select>
                                            </div>
                                        </td>                                                            
                                    </tr>
                                    <tr>
                                        <td class="tableSubtitle odd">SKU</td>
                                        <td class="tableContent" colspan="3">
                                            <input class="form-control" type="text" name="sku" readonly />
                                            <span id="searchNotMsg" ></span>
                                        </td>                                                            
                                    </tr>
                                    <tr>
                                        <td class="tableSubtitle even"><?=lang('peijian_sl')?>(Editable)</td>
                                        <td class="tableContent" colspan="3">
                                            <br>
                                            <input class="form-control" type="text" name="quantity" value="1" onkeyup="this.value=this.value.replace(/[^1-9]/g,'')" />
                                            <h3 class="panel-title" style="margin: 10px 0 5px 0;"><?= lang('peijian_kcsl') ?>:</h3>
                                            <input class="form-control" type="text" name="stockQuantity" value="" readonly size="12">
                                            <label style="color:#1e91cf;"><?=lang('peijian_stockNote')?></label>
                                            <br>
                                        </td>                                                            
                                    </tr>
                                    <tr>
                                        <td class="tableSubtitle odd"><?=lang('peijian_sj')?></td>
                                        <td class="tableContent" colspan="3">
                                            <input class="form-control" type="text" name="price"  readonly />
                                        </td>                                                            
                                    </tr>
                                    <tr>
                                        <td class="tableSubtitle even"><?=lang('order_hb')?></td>
                                        <td class="tableContent" colspan="3">
                                            <input class="form-control" type="text" name="currency" readonly />
                                        </td>                                                            
                                    </tr>
                                    <tr>
                                        <td class="tableSubtitle odd"><?=lang('peijian_sfhx')?></td>
                                        <td class="tableContent" colspan="3">
                                            <input class="form-control" type="text" name="able_write_off" readonly />
                                        </td>                                                            
                                    </tr>
                                  </tbody>
                                </table>
                                <div class="form-group">
                                    <label class="col-sm-2 control-label"></label>
                                    <div class="col-sm-10">
                                        <input type="hidden" name="cost_price" />
                                        <input type="hidden" name="whs_code" />
                                        <input type="hidden" name="type" />
                                        <input type="hidden" name="pid" value="<?=$productFirst['id']?>"/>
                                        <input type="hidden" name="oid" value="<?=$productFirst['oid']?>"/>
                                        <input type="hidden" name="point" value="<?=$orderFirst['point']?>"/>
                                        <input type="hidden" name="order_num" value="<?=$productFirst['order_num']?>"/>
                                        <input type="button" class="btn btn-primary pull-right" style="padding:8px 30px;margin-left: 5px;" value="<?=lang('peijian_tjpj')?>" name="addParts" id="addPartsId" />
                                        <input class="btn btn-oms pull-right" style="padding:8px 30px;" type="reset" value="reset" name="resetAddParst" />
                                    </div>
                                </div>
                                <div class="form-group">
                                    <label class="col-sm-2 control-label"></label>
                                    <div class="col-sm-10">
                                        <input class="btn btn-primary pull-right" style="padding:8px 30px;" onclick="return quoteRepair()" type="button" value=" 维修报价完毕 ">
                                    </div>
                                </div>
                                </form>      
                            </div>
                        </div>
               
                    </div>
                </div>
            </div>
        </div>
    </div>

<div id="hqDIV" style="display: none">
    <ul class="layer_notice">
        <li>环球易购配件信息同步：<span id="hqpjMsg"><img style="width: 50px;height: 10px;" src="<?=base_url()?>resource/images/loading_h.gif"></span></li>
        <li>环球易购维修报价信息同步：<span id="hqbjMsg"><img style="width: 50px;height: 10px;" src="<?=base_url()?>resource/images/loading_h.gif"></span></li>
        <li>&nbsp;</li>
        <li style="list-style-type:none;text-align: center;"><input style="width: 80px;;height: 25px;" type="button" value=" OK " onclick="hqUrl()"></li>
    </ul>
</div>

<style>
    #partsFormId .tableSubtitle {width:10%;}
</style>
<script type="application/javascript">
    $(function(){
        //获取配件列表
        $('#search input[name="name"]').keydown(function(e){
            var partsName = $.trim($(this).val());
            var oid = $("input[name=oid]").val();
            var pid = $("input[name=pid]").val();
            var sku="<?=$productFirst['productSku']?>";
            var scope= $('input[name="scope"]:checked ').val();
            var position= $("select[name=position]").val();
            if(partsName == "" || partsName.length<3 || e.keyCode != 32){
                $('#search_auto').css('display', 'none')
            }else {
                $("#searchNotMsg").html("load in....");
                $.ajax({
                    type:'POST',
                    url:"<?=blang_url('common/Com_ajax/getPartsList')?>",
                    data:{keyword:partsName,oid:oid,pid:pid,sku:sku,scope:scope,position:position},
                    async:false,
                    success:function(data){
                        if(!data){
                           // $("input[name='resetAddParst']").click();
                            $('#part_select').val('');
                            $("input[name='sku']").val('');
                            $("input[name='price']").val('');
                            $("input[name='currency']").val('');
                            $("input[name='cost_price']").val('');
                            $("input[name='stockQuantity']").val('');
                            $("input[name='able_write_off']").val('');
                            $("input[name='whs_code']").val('');
                            $("input[name='type']").val('');
                            $('#search input[name="name"]').val(partsName);
                            $('#search_auto').css('display', 'none');
                            $("#searchNotMsg").html("<?=lang('peijian_notFoundMsg')?>");
                        }else{
                            $("#searchNotMsg").html('');
                            $('#search_auto').html(data).css('display', 'block');
                        }
                    }
                });
            }
        });
        //添加配件
        $("#addPartsId").click(function(){
            var name_a = $.trim($("#name_name").val());
            var name_b = $.trim($("#part_select").val());
            if(name_a=='' && name_b==''){
                alert('<?=lang('peijian_qsrpjmc')?>');
                return false;
            }
            $(this).prop('disabled',true);
            var postData = $("#partsFormId").serialize();
            $.post("<?=blang_url('common/Com_ajax/addParts')?>", postData,
                function(data){
                    $('#partsListId').html(data);
                    $("#addPartsId").prop('disabled',false);
                    $('#name_name').val('');
                    $('#part_select').val('');
                    $("input[name='sku']").val('');
                    $("input[name='price']").val('');
                    $("input[name='currency']").val('');
                    $("input[name='cost_price']").val('');
                    $("input[name='stockQuantity']").val('');
                    $("input[name='able_write_off']").val('');
                    $("input[name='whs_code']").val('');
                    $("input[name='type']").val('');
                }
            );
        });
        //默认显示配件列表
        $.get("<?=blang_url('common/Com_ajax/partsList/'.$productFirst['id'])?>", function(data){
                $('#partsListId').html(data);
            }
        );
        /*是否质保选项触发显示质保证明图*/
        function getObjectURL(file) {
            var url = null ;
            if (window.createObjectURL!=undefined) { // normal
                url = window.createObjectURL(file) ;
            } else if (window.URL!=undefined) { // firefox
                url = window.URL.createObjectURL(file) ;
            } else if (window.webkitURL!=undefined) { // google
                url = window.webkitURL.createObjectURL(file) ;
            }
            return url ;
        }

        $(".inputinWarranty").on("change",function(){
            var inputChecked = $(".input-no").is(':checked');
            if(inputChecked){
                $('<div class="form-group descriptionConsistent-relation"><label class="col-sm-2 control-label">保外证明图</label><div class="col-sm-10"><ul class="position-img"> <li> <div class="img-area"><img src="<?=base_url()?>resource/images/null.png" old-src="<?=base_url()?>resource/images/null.png"> </div> <input type="file" name="warranty_img_1" class="upload-img" accept="image/gif, image/jpeg, image/png"> </li> <li> <div class="img-area"> <img src="<?=base_url()?>resource/images/null.png" old-src="<?=base_url()?>resource/images/null.png"> </div> <input type="file" name="warranty_img_2" class="upload-img" accept="image/gif, image/jpeg, image/png"> </li> <li> <div class="img-area"> <img src="<?=base_url()?>resource/images/null.png" old-src="<?=base_url()?>resource/images/null.png"> </div> <input type="file" name="warranty_img_3" class="upload-img" accept="image/gif, image/jpeg, image/png"> </li> </ul> <div class="clear"></div> </div> </div>').insertAfter($(this).parent().parent().parent());
                var str;
                $('input.upload-img').on("change",function(){
                    str=$(this).val();
                    if(str != ""){
                        var oldImgUrl = $(this).siblings('.img-area').find('img').attr("old-src");
                        if(/\.(?:png|PNG|jpg|JPG|gif|PNG)$/.test(str)){
                            var objUrl = getObjectURL(this.files[0]);
                            if (objUrl) {
                                $(this).siblings('.img-area').find('img').attr("src", objUrl);
                            }
                        }else{
                            alert("选择文件错误,图片类型必须是(gif,jpeg,jpg,bmp,png)中的一种");
                            $(this).val("");
                            $(this).siblings('.img-area').find('img').attr("src", oldImgUrl);
                        }
                    }
                });
            }else{
                $(".descriptionConsistent-relation").remove();
            }
        });
        $("input[name='scope']").click(function(){
            var scopeVal= $(this).val();
            if(scopeVal==1){
                $('#partsPosition').css('display', 'none');
                $('#search').css('display', 'block');
                $('#part_list').css('display', 'none');
                $('#name_name').val('');
            }else{
                $('#partsPosition').css('display', 'block');
                $('#search').css('display', 'none');
                $('#search_auto').css('display', 'none');
                $('#part_list').css('display', 'block');
                $('#part_select').val('');
            }
            $("input[name='sku']").val('');
            $("input[name='price']").val('');
            $("input[name='currency']").val('');
            $("input[name='cost_price']").val('');
            $("input[name='stockQuantity']").val('');
            $("input[name='able_write_off']").val('');
            $("input[name='whs_code']").val('');
            $("input[name='type']").val('');
        });
    });
    function addParts_two(partsObj,type) {
         var obj = JSON.parse(decodeURIComponent(partsObj));
         console.log(obj);
         if(type==1) {
             $("#name_name").val(obj.name);
         }else{
             $("#name_select").val(obj.name);
         }
         $("input[name='sku']").val(obj.sap_sku);
         $("input[name='price']").val(obj.price);
         $("input[name='currency']").val(obj.currency);
         $("input[name='cost_price']").val(obj.cost_price);
         $("input[name='stockQuantity']").val(obj.quantity);
         $("input[name='able_write_off']").val(obj.able_write_off);
         $("input[name='whs_code']").val(obj.whs_code);
         $("input[name='type']").val(obj.type);
         $('#search_auto').css('display', 'none');
    }
    function keyUp(){
        var point = "<?=$orderFirst['point']?>";
        var merchant_num = "<?=$orderFirst['merchant_num']?>";
        var brandCustomerNum="<?=$productFirst['brandCustomerNum']?>";
        var model_id="<?=$productFirst['model_id']?>";
        var inWarranty = "<?=$productFirst['inWarranty']?>";
        var sku="<?=$productFirst['productSku']?>";
        var position= $("select[name=position]").val();
        var index = layer.load(2);
        var html="<option value=''>--请选择--</option>";
        $.post("<?=blang_url('common/Com_ajax/getPortionPart/')?>",{'point':point,'merchant_num':merchant_num,'inWarranty':inWarranty,'sku':sku,'position':position,'brandCustomerNum':brandCustomerNum,'model_id':model_id},function(data){
            if(data){
                layer.close(index);
                var obj = JSON.parse(data);
                for(var i=0;i<obj.length;i++){
                    html+="<option value='"+obj[i]['jsonData']+"'>"+obj[i]['name']+"&nbsp;&nbsp;"+obj[i]['sku']+"</option>";
                }
                $('#part_select').html(html);
            }else{
                layer.close(index);
                $("#name_select").val('');
                $("input[name='sku']").val('');
                $("input[name='price']").val('');
                $("input[name='currency']").val('');
                $("input[name='cost_price']").val('');
                $("input[name='stockQuantity']").val('');
                $("input[name='able_write_off']").val('');
                $("input[name='whs_code']").val('');
                $("input[name='type']").val('');
                $('#part_select').html(html);
            }
        });
    }
</script>

</div>



